/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _ACTIVITY_HEADER_HPP_
#define _ACTIVITY_HEADER_HPP_

#include <DateTime.hpp>
#include <Duration.hpp>
#include <libxml++/libxml++.h>
//#include <lap-header.hpp>
#include <Interval.hpp>

///@class ActivityHeader
///@brief Defines the header with summarized informations on an activity
class ActivityHeader
{
    public:
        ///@brief Default constructor
        ActivityHeader();
        ///@brief Copy constructor
        ActivityHeader(const ActivityHeader&);
        ///@brief Destructor
        ~ActivityHeader();
        ///@brief Overload of = operator
        ActivityHeader &operator=(const ActivityHeader&);
        /*///@brief Add a new lap header
        void AddLap(LapHeader);*/
        ///@brief Recompute header values from values in the laps headers
        void Recompute();
        
        ///SETTERS
        
        ///@brief Set the distance value;
        void SetDistance(double);
        ///@brief Set the duration value
        void SetDuration(Duration);
        ///@brief Set the date value
        void SetDateTime(DateTime);
        ///@brief Set the activity type
        void SetActivityType(std::string);
        ///@brief Set FC Moy value
        void SetFCMoy(unsigned int);
        ///@brief Set FC Max value
        void SetFCMax(unsigned int);
        ///@brief Set the location
        void SetLocation(std::string);
        ///@brief Set the comments
        void SetComments(std::string);
        ///@brief Set the consumed calories
        void SetCalories(unsigned int);
        ///@brief Set the trained quality
        void SetQuality(std::string);
        ///@brief Set the time spent in a given intensity zone
        void SetTimeInZone(unsigned int, double);
        ///@brief Set the maximum speed
        void SetMaximumSpeed(double);
        ///@brief Set the average power
        void SetAveragePower(double);
        
        ///GETTERS
        
        ///@brief Return the ID
        std::string GetId() const;
        ///@brief Return the date
        DateTime GetDateTime() const;
        ///@brief Return location
        std::string GetLocation();
        ///@brief Return activity type
        std::string GetActivityType();
        ///@brief Return the distance
        double GetDistance();
        ///@brief Return the duration
        Duration GetDuration();
        ///@brief Return FC moy
        unsigned int GetFCMoy();
        ///@brief Return FC max
        unsigned int GetFCMax();
        ///@brief Return comments
        std::string GetComments();
        ///@brief Return consumed calories
        unsigned int GetCalories();
        ///@brief Return trained quality
        std::string GetQuality();
        ///@brief Return time spent in a given intensity zone
        double GetTimeInZone(unsigned int);
        ///@brief Return the maximum speed
        double GetMaximumSpeed();
        ///@brief Return the average cadence
        unsigned int GetAverageCadence();
        ///@brief Return the average power
        double GetAveragePower();
        
        ///IMPORT FROM DIFFERENT TYPES OF FILES
        ///@brief Read activity header from a XML node in a Tcx File
        void ReadFromTcxFile(xmlpp::Node*);

        ///@brief Read activity header form a trainingbook XML file
        void ReadXMLNode(xmlpp::Node*);
        
        ///WRITE IN DIFFERENT TYPES OF FILE
        ///@brief Write to XML native file
        void WriteXML(std::ofstream &fout);
        
        ///@brief Overload of < operator to sort activities depending on their date
        friend bool operator < (const ActivityHeader& , const ActivityHeader&);


        
    private:
        ///@brief Activity ID
        std::string id;
        ///@brief Activity date and time
        DateTime date;
        ///@brief Activity location
        std::string location;
        ///@brief Activity type
        std::string type;
        ///@brief Distance
        float distance;
        ///@brief Duration
        Duration duration;
        ///@brief Mean heart rate
        unsigned int fcMoy;
        ///@brief Maximum heart rate
        unsigned int fcMax;
        ///@brief Comments on the activity
        std::string comments;
        ///@brief Number of consumed kilocalories (in Cal == kcal)
        unsigned int calories;
        ///@brief Trained quality
        std::string quality;
        ///@brief Intensity repartition in ESIE scale (in minutes)
        double intensity[7];
        ///@brief Maximum speed in km/h
        double maxSpeed;
        ///@brief Average cadence in RPM
        unsigned int cadence;
        ///@brief Average power in W
        double power;
        /*///@brief List of lap headers
        std::list<LapHeader> laps;*/
        ///@brief Array of intervals
        std::vector<Interval> intervals;
        
};

#endif